package logic

import (
	"context"
	"wechats/wechatrpc/wechatrpc"

	"wechats/api/internal/svc"
	"wechats/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectLogic {
	return &PerfectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerfectLogic) Perfect(req *types.PerfectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	perfect, err := l.svcCtx.WechatRpc.Perfect(l.ctx, &wechatrpc.PerfectRequest{
		Id:      req.Id,
		Image:   req.Image,
		Name:    req.Name,
		Hao:     req.Hao,
		Address: req.Address,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	} else {

		return &types.Response{
			Message: "完善信息成功",
			Code:    200,
			Data:    perfect,
		}, nil
	}
}
